import { create, getTask } from '@/api/task'
import {getToken} from "@/utils/auth"

const state = {
  token: getToken()
}

const mutations = {
  SET_TOKEN: (state, token) => {
    state.token = token
  }
}

const actions = {
  create({ commit }, data) {
    return new Promise((resolve, reject) => {
      create(data).then(response => {
        console.log(data,response)
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  // task getInfo
  getInfo({ commit }, data) {
    console.log('get here task')
    return new Promise((resolve, reject) => {
      getTask(data).then(response => {
        console.log(response)
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
